package com.mzj.saas.mservice.property.repository;

import com.mzj.saas.mservice.property.entity.ComplainSuggestReply;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author hikari
 * @since 2021-05-13
 */
@Repository
public interface ComplainSuggestReplyRepository extends JpaRepository<ComplainSuggestReply, Long>, JpaSpecificationExecutor<ComplainSuggestReply> {
    Page<ComplainSuggestReply> findByComplainSuggestId(Long complainSuggestId, Pageable pageable);

    List<ComplainSuggestReply> findByComplainSuggestId(Long complainSuggestId);

    @Query(value = "SELECT COUNT(1) FROM saas_complain_suggest_reply where type = ?1 and complain_suggest_id = ?2", nativeQuery = true)
    int findCountByTypeAndCSId(Integer type, Long complainSuggestId);


}
